#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int n,k;
int path;
int ret = 0;

bool isPrime(int n) {
    if (n <= 1) {
        return false; 
    }
    for (int i = 2; i <= sqrt(n); ++i) { 
        if (n % i == 0) {
            return false; 
        }
    }
    return true; 
}

void dfs(vector<int>& nums,int pos,int level)
{
    if(level == k)
    {
        if(isPrime(path)) ret++;
        return;
    }
    
    for(int i = pos; i < n;i++)
    {
        path += nums[i];
        dfs(nums,i+1,level + 1);
        path -= nums[i];
    }
}

int main()
{
    cin >> n >> k;
    int num;
    vector<int> nums;
    for(int i = 0; i < n;i++)
    {
        cin >> num;
        nums.push_back(num);
    }   
    
    dfs(nums,0,1);
    
    cout << ret << endl;
    return 0;
}
